package com.study.talk.dao;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.study.talk.entity.GroupMessageRecord;

import java.util.List;

@Dao
public interface GroupMessageDao {

    @Insert
    void insertMessage(GroupMessageRecord message);

    @Insert
    void insertMessageList(List<GroupMessageRecord> messageList);

    @Delete
    void deleteMessage(GroupMessageRecord message);

    @Update
    void updateMessage(GroupMessageRecord message);

    @Query("SELECT * FROM group_message_record")
    List<GroupMessageRecord> getAll();

    @Query("DELETE FROM group_message_record")
    void deleteAll();

    @Query("SELECT * FROM group_message_record WHERE group_id=(:groupId)")
    List<GroupMessageRecord> getListByGroupId(Integer groupId);

    @Query("UPDATE group_message_record SET read = 1 WHERE group_id=(:groupId)")
    Integer updateMessageRead(Integer groupId);

}
